package com.xyy.saas.payment.pojo.vo;

import com.xyy.saas.payment.exception.PaymentException;
import com.xyy.saas.payment.manage.cores.enums.ResultCodeEnum;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author wangzeqi
 */
@Data
public class UserAccountWithdrawalDTO implements Serializable {

    private static final long serialVersionUID = 8973044553772725661L;

    private String userId;

    private String amount;

    public void checkParam() throws PaymentException {
        if (StringUtils.isBlank(userId) || StringUtils.isBlank(amount) ||
                !NumberUtils.isCreatable(amount) || new BigDecimal(amount).compareTo(BigDecimal.ZERO) <= 0) {
            throw new PaymentException(ResultCodeEnum.PARAM_ERROR);
        }
    }

}
